import { rootRoute, errorRoutes, loginRoute } from './baisc';
import {adminRouter} from "@/router/modules/admin";
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
import { setupRouterGuard } from './guard';
import { registerDynamicRoutes } from './merge';

const routes = [rootRoute, loginRoute, ...errorRoutes,adminRouter];
// const routes = [rootRoutes, loginRoute, ...appRoutes, ...errorRoutes];
const router = createRouter({
  history: createWebHistory(),
  routes,
  strict: true,
  scrollBehavior: () => ({ left: 0, top: 0 })
});

export function setupRouter(app) {
  registerDynamicRoutes(router);
  app.use(router);
  setupRouterGuard(router);
  return router;
}

export default router;
